<!--
 * @Descripttion: 
 * @version: 
 * @Author: siebe
 * @Date: 2022-02-18 15:45:23
 * @LastEditors: siebe
 * @LastEditTime: 2022-02-19 21:26:18
-->
{include file="public/header" /}
<form class="layui-form">
    <div class="layui-form-item">
        <input type="hidden" name="__token__" value="{:token()}" />
        <label class="layui-form-label">账号</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="username" placeholder="请输入账号">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">密码</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="password" placeholder="请输入密码">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">姓名</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="name" placeholder="请输入姓名">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">昵称</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="nickname" placeholder="请输入昵称">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">部门</label>
        <div class="layui-input-inline">
            <select name="group_id" id="">
                <option value="0"></option>
                {foreach ($group as $item)}
                    <option value="{$item.id}">{$item.name}</option>
                {/foreach}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号</label>
        <div class="layui-input-inline">
            <input type="text" class="layui-input" name="contact_phone" placeholder="请输入手机号">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="开启" checked="">
            <input type="radio" name="status" value="0" title="禁用">
        </div>
    </div>
</form>
<div class="layui-form-item">
    <div class="layui-input-block">
        <button type="button" class="layui-btn" onclick="save()">保存</button>
    </div>
</div>
<script type="text/javascript">
    layui.use(['form'],function(){
        form = layui.form;
        $ = layui.jquery
    });
    function save(){
        $.post("{$config.path}user/add",$('form').serialize(),function(res){
            if(res.error_code == 0){
				layer.msg(res.msg, { 'icon': 1 });
				setTimeout(function () {
					parent.window.location.reload();
				}, 1000);
			}else{
				layer.msg(res.msg, { 'icon': 2 });
			}
		},'json').error(function (res) {
			layer.msg(res.responseJSON.msg, { 'icon': 2 });
		});
    }
</script>
</body>
</html>